<template>
  <div class="goods-item" @click="toGoodsPage(goods.id)">
    <img :src="goods.banner[0].url" alt="" />
    <div class="title">
      {{ goods.name }}
    </div>
    <div class="tags">
      <div class="item" v-for="(item, index) in goods.promotion" :key="index">
        {{ item }}
      </div>
    </div>
    <div class="info">
      <div class="sales">
        销量 <span>{{ goods.sale }}</span>
      </div>
      <div class="spec">
        规格<span>>{{ goods.specifications.length }}种</span>
      </div>
    </div>
    <div class="price">
      <b>¥ {{ goods.starting_price }}</b
      ><s v-if="goods.price">¥ {{ goods.price }}</s>
    </div>
  </div>
</template>

<script>
// 店铺页面商品详情
export default {
  name: "GoodsItem7",
  props: {
    goods: Object,
  },
};
</script>

<style lang="scss" scoped>
.goods-item {
  width: 224px;
  height: 367px;
  font-size: 0;
  box-sizing: border-box;
  background: #ffffff;
  border: 1px solid #f0f0f0;
  border-radius: 5px;
  margin-left: 20px;
  margin-bottom: 20px;
  display: inline-block;
  position: relative;
  &:hover {
    border: 1px solid #d52c1a;
    .add-car {
      display: flex;
    }
  }
  img {
    width: 200px;
    height: 200px;
    border-radius: 5px;
    padding: 12px;
  }
  .title {
    padding: 0 12px;
    font-size: 16px;
    font-weight: 400;
    color: #333333;
    height: 44px;
    line-height: 22px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }
  .tags {
    padding: 9px 12px 8px;
    .item {
      display: inline-block;
      background: #dc2c1a;
      border-radius: 5px;
      padding: 3px 10px;
      line-height: 14px;
      font-size: 10px;
      font-weight: 400;
      color: #ffffff;
      margin-left: 12px;
      cursor: pointer;
      &:first-child {
        margin-left: 0;
      }
    }
  }
  .info {
    padding: 0 12px;
    display: flex;
    justify-content: space-between;
    font-size: 14px;
    font-weight: 400;
    color: #999999;
    line-height: 20px;
  }
  .price {
    padding: 6px 12px 5px;
    b {
      font-size: 18px;
      font-weight: 500;
      color: #d52c1a;
      line-height: 25px;
    }
    s {
      font-size: 14px;
      font-weight: 400;
      color: #999999;
      line-height: 20px;
      padding-left: 8px;
    }
  }
  .shop {
    height: 34px;
    padding: 0 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    font-weight: 400;
    color: #999999;
    line-height: 20px;
    border-top: 1px solid #f0f0f0;
    cursor: pointer;
  }
  .add-car {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 34px;
    padding: 0 12px;
    display: none;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid #f0f0f0;
    button {
      width: 160px;
      height: 28px;
      background: #d52c1a;
      border-radius: 5px;
      font-size: 14px;
      color: #fff;
      border: none;
      outline: none;
    }
  }
}
</style>
